package com.mqtt.ctwingmqtt.service.Impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.mqtt.ctwingmqtt.domain.entity.NbHouseholdValvesHistory;
import com.mqtt.ctwingmqtt.mapper.NbHouseholdValvesHistoryMapper;
import com.mqtt.ctwingmqtt.service.NbHouseholdValvesHistoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class NbHouseholdValesHistoryServiceImpl implements NbHouseholdValvesHistoryService {
    @Autowired
    private NbHouseholdValvesHistoryMapper nbHouseholdValvesHistoryMapper;
    @Override
    public NbHouseholdValvesHistory getOne(LambdaQueryWrapper<NbHouseholdValvesHistory> historyWrapper) {
        return null;
    }

    @Override
    public void save(NbHouseholdValvesHistory nbHouseholdValvesHistory) {
        nbHouseholdValvesHistoryMapper.insert(nbHouseholdValvesHistory);
    }
    @Override
    public List<NbHouseholdValvesHistory> findByDeviceAddress(String deviceAddress) {
        LambdaQueryWrapper<NbHouseholdValvesHistory> wrapper = Wrappers.lambdaQuery();
        if(deviceAddress!=null && !"".equals(deviceAddress))
            wrapper.eq(NbHouseholdValvesHistory::getDeviceAddress, deviceAddress);
        return nbHouseholdValvesHistoryMapper.selectList(wrapper);
    }
}
